package com.linln.admin.rate;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.linln.common.vo.JsonResult;
import com.linln.common.vo.PageResult;
import com.linln.modules.activityticket.domain.ActivityTicket;
import com.linln.modules.rate.domain.Rate;
import com.linln.modules.rate.service.RateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @author : pengliang
 * @version V1.0
 * @Project: timo
 * @Package com.linln.admin.rate
 * @Descriptio /**
 * @Project: timo
 * @Package com.linln.admin.rate
 * @Description: TODO
 * @date Date : 2021年01月05日 15:17
 */
@Controller
@RequestMapping("rate")
public class RateController {
    @GetMapping("/index")
    public String index() {
        return "/rate/index";
    }

    @Autowired
    private RateService rateService;

    @GetMapping()
    @ResponseBody
    public PageResult getRateList(@RequestParam(required = false, defaultValue = "0") Integer page, @RequestParam(required = false, defaultValue = "10") Integer limit,
                                  @RequestParam(required = false) String shopName, @RequestParam(required = false) Integer status) {
        return rateService.getRateList(page, limit, shopName, status);
    }


    @PostMapping()
    @ResponseBody
    public JsonResult updateRateStatus(String rateId, Integer status, String shopId) {
        return rateService.updateRateStatus(rateId, status, shopId) ? JsonResult.ok() : JsonResult.error();
    }

    @PostMapping("/batch")
    @ResponseBody
    public JsonResult batchUpdateRateStatus(@RequestParam("rateIds") ArrayList<String> rateIds, Integer status,@RequestParam("shopIds") HashSet<String> shopIds) {
        return rateService.batchUpdateRateStatus(rateIds, status, shopIds) ? JsonResult.ok() : JsonResult.error();
    }


}
